﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using YearsGoneBy.Models;
using YearsGoneBy.ViewModels.Home;

namespace YearsGoneBy.Controllers
{
    public class HomeController : Controller
    {
        protected YearsGoneByConnection _data = new YearsGoneByConnection();

        public ActionResult Index()
        {
            var Photos = _data.Photos.Where(x => x.Active == true).ToList();

            var PhotosViewModel = new PhotosViewModel()
            {
                PhotoList = Photos.Select(x => new PhotosList
                {
                    PhotoDescription = x.PhotoDescription,
                    PhotoLocation = x.PhotoLocation,
                    Photo = x.Photo1,

                })
             .ToList()
            };


            return View(PhotosViewModel);
            //return View(FillViewModel());
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public PhotosViewModel FillViewModel()
        {
            var PhotoViewModelItems = new PhotosViewModel();

            PhotoViewModelItems.PhotoList.Add(new PhotosList
            {
                Photo = "test",
                PhotoDescription = "test",
                PhotoLocation = "test",

            });

            return PhotoViewModelItems;
        }
    }
}